package com.sky.controller.courier;

import com.sky.pojo.CourierTradeOrder;
import com.sky.result.Result;
import com.sky.service.courier.CourierTradeService;
import com.sky.vo.CourierTradeOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 骑手运单控制器层
 *
 * @author zgp
 * @version V1.0
 * @date 2025-02-20 11:15
 */
@Slf4j
@Api(tags = "骑手运单相关接口")
@RestController
@RequestMapping("/trade")
public class CourierTradeController {
    @Autowired
    private CourierTradeService courierTradeService;


    @ApiOperation("待接单查询")
    @GetMapping("/queryPendingOrders")
    public Result<List<CourierTradeOrderVO>> getPendingOrders(Integer status, Integer courierId) {
        log.info("骑手待接单订单信息查询：courierId = {}, status = {}", courierId, status);
        return Result.success(courierTradeService.getPendingOrders(status, courierId));
    }

    @ApiOperation("待取货查询")
    @GetMapping("/queryTobePickedUpTradeOrders")
    public Result<List<CourierTradeOrderVO>> getTobePickedUpTradeOrders(Integer status, Integer courierId){
        log.info("骑手待取货订单信息查询：courierId = {}, status = {}", courierId, status);
        return Result.success(courierTradeService.getPendingOrders(status, courierId));
    }

    @ApiOperation("待送达查询")
    @GetMapping("/toBedeliveredList")
    public Result<List<CourierTradeOrderVO>> getToBedeliveredList(Integer status, Integer courierId){
        log.info("骑手待送达订单信息查询：courierId = {}, status = {}", courierId, status);
        return Result.success(courierTradeService.getPendingOrders(status, courierId));
    }

    @ApiOperation("待送达查询")
    @GetMapping("/queryCanceldTradeOrderList")
    public Result<List<CourierTradeOrderVO>> getCanceldTradeOrderList(Integer status, Integer courierId){
        log.info("骑手已取消订单信息查询：courierId = {}, status = {}", courierId, status);
        return Result.success(courierTradeService.getPendingOrders(status, courierId));
    }

    @ApiOperation("根据订单号查询运单")
    @GetMapping("/queryTradeOrderByTradeNo")
    public Result<CourierTradeOrder> getTradeOrderByOrderNo(String tradeNo){
        log.info("根据订单号查询运单：tradeNo = {}", tradeNo);
        return Result.success(courierTradeService.getTradeOrderByOrderNo(tradeNo));
    }


}
